package com.graduationproject.examonline.notice.controller;

import com.graduationproject.examonline.notice.service.NoticeService;
import com.graduationproject.examonline.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("api/notice")
public class NoticeController {
    @Autowired
    private NoticeService noticeService;

    @GetMapping("/getNoticeByUserId")
    public Result getNoticeByUserId(String user_id) {
        return noticeService.getNoticeByUserId(user_id);
    }

    @GetMapping("/getNoticeByCreateUser")
    public Result getNoticeByCreateUser(String user_id) {
        return noticeService.getNoticeByCreateUser(user_id);
    }

    @GetMapping("/checkNotice")
    public Result readNoticeById(String notice_id) {
        return noticeService.checkNotice(notice_id);
    }

    @PostMapping("/checkNotice")
    public Result checkNotice(@RequestBody Map<String, Object> params) {
        return noticeService.checkNotice((String) params.get("notice_id"));
    }

    @PostMapping("/deletedNotice")
    public Result deletedNotice(@RequestBody Map<String, Object> params) {
        return noticeService.deletedNotice((String) params.get("notice_id"));
    }

    @PostMapping("/createNotice")
    public Result createNotice(@RequestBody Map<String, Object> params) {
        return noticeService.createNotice(params);
    }
}
